@@ -83,6 +83,14 @@ public class Preferences { |
||
83 | 83 |
} |
84 | 84 |
|
85 | 85 |
|
86 |
+ public void setCameraQueryInterval(int interval){ |
|
87 |
+ mPrefs.edit().putInt("interval",interval).commit(); |
|
88 |
+ } |
|
89 |
+ |
|
90 |
+ public int getCameraQueryInterval(){ |
|
91 |
+ return mPrefs.getInt("interval",50); |
|
92 |
+ } |
|
93 |
+ |
|
86 | 94 |
public void clearPrefs(){ |
87 | 95 |
mPrefs.edit().clear().commit(); |
88 | 96 |
} |
@@ -14,6 +14,8 @@ import com.android.common.utils.LogHelper; |
||
14 | 14 |
import java.util.Timer; |
15 | 15 |
import java.util.TimerTask; |
16 | 16 |
|
17 |
+import ai.pai.lensman.db.Preferences; |
|
18 |
+ |
|
17 | 19 |
public class CameraService extends Service { |
18 | 20 |
|
19 | 21 |
private boolean isInitExecuted; |
@@ -170,7 +172,7 @@ public class CameraService extends Service { |
||
170 | 172 |
public void run() { |
171 | 173 |
fetchPhotoTask(); |
172 | 174 |
} |
173 |
- },1000,10); |
|
175 |
+ },1000, Preferences.getInstance().getCameraQueryInterval()); |
|
174 | 176 |
} |
175 | 177 |
|
176 | 178 |
public void stopCapture(){ |
@@ -126,9 +126,13 @@ class MainPresenter implements MainContract.Presenter,SyncTimeInteractor.SyncTim |
||
126 | 126 |
|
127 | 127 |
@Override |
128 | 128 |
public void stop() { |
129 |
- App.getAppContext().unbindService(uploadServiceConnection); |
|
130 |
- App.getAppContext().unbindService(orderServiceConnection); |
|
131 |
- App.getAppContext().unregisterReceiver(wifiReceiver); |
|
129 |
+ try{ |
|
130 |
+ App.getAppContext().unbindService(uploadServiceConnection); |
|
131 |
+ App.getAppContext().unbindService(orderServiceConnection); |
|
132 |
+ App.getAppContext().unregisterReceiver(wifiReceiver); |
|
133 |
+ }catch (Exception e){ |
|
134 |
+ e.printStackTrace(); |
|
135 |
+ } |
|
132 | 136 |
} |
133 | 137 |
|
134 | 138 |
@Override |
@@ -3,6 +3,8 @@ package ai.pai.lensman.settings; |
||
3 | 3 |
import android.content.Intent; |
4 | 4 |
import android.os.Bundle; |
5 | 5 |
import android.support.annotation.Nullable; |
6 |
+import android.widget.EditText; |
|
7 |
+import android.widget.Toast; |
|
6 | 8 |
|
7 | 9 |
import ai.pai.lensman.R; |
8 | 10 |
import ai.pai.lensman.activities.AboutUsActivity; |
@@ -11,17 +13,21 @@ import ai.pai.lensman.activities.WebViewActivity; |
||
11 | 13 |
import ai.pai.lensman.base.BaseActivity; |
12 | 14 |
import ai.pai.lensman.db.Preferences; |
13 | 15 |
import ai.pai.lensman.login.LoginActivity; |
16 |
+import butterknife.BindView; |
|
14 | 17 |
import butterknife.ButterKnife; |
15 | 18 |
import butterknife.OnClick; |
16 | 19 |
|
17 | 20 |
|
18 | 21 |
public class SettingsActivity extends BaseActivity { |
19 | 22 |
|
23 |
+ @BindView(R.id.et_query_interval) EditText cameraQueyInterval; |
|
24 |
+ |
|
20 | 25 |
@Override |
21 | 26 |
protected void onCreate(@Nullable Bundle savedInstanceState) { |
22 | 27 |
super.onCreate(savedInstanceState); |
23 | 28 |
setContentView(R.layout.activity_settings); |
24 | 29 |
unbinder = ButterKnife.bind(this); |
30 |
+ cameraQueyInterval.setText(String.valueOf(Preferences.getInstance().getCameraQueryInterval())); |
|
25 | 31 |
} |
26 | 32 |
|
27 | 33 |
|
@@ -57,4 +63,22 @@ public class SettingsActivity extends BaseActivity { |
||
57 | 63 |
finish(); |
58 | 64 |
} |
59 | 65 |
|
66 |
+ @OnClick(R.id.btn_confirm_interval) |
|
67 |
+ void confirmInterval(){ |
|
68 |
+ if(cameraQueyInterval.getText()!=null && !cameraQueyInterval.getText().toString().isEmpty()){ |
|
69 |
+ try{ |
|
70 |
+ int interval = Integer.parseInt(cameraQueyInterval.getText().toString()); |
|
71 |
+ if(interval>=10 && interval<=2000){ |
|
72 |
+ Preferences.getInstance().setCameraQueryInterval(interval); |
|
73 |
+ Toast.makeText(this,"设置成功,间隔是",Toast.LENGTH_SHORT).show(); |
|
74 |
+ finish(); |
|
75 |
+ }else{ |
|
76 |
+ Toast.makeText(this,"间隔应该在[10,2000]区间内",Toast.LENGTH_SHORT).show(); |
|
77 |
+ } |
|
78 |
+ }catch (Exception e){ |
|
79 |
+ e.printStackTrace(); |
|
80 |
+ } |
|
81 |
+ } |
|
82 |
+ } |
|
83 |
+ |
|
60 | 84 |
} |
@@ -157,7 +157,6 @@ |
||
157 | 157 |
|
158 | 158 |
</LinearLayout> |
159 | 159 |
|
160 |
- |
|
161 | 160 |
<View |
162 | 161 |
android:layout_width="match_parent" |
163 | 162 |
android:layout_height="1px" |
@@ -189,7 +188,7 @@ |
||
189 | 188 |
android:gravity="center" |
190 | 189 |
android:textSize="16sp" |
191 | 190 |
android:textColor="@color/dark_grey" |
192 |
- /> |
|
191 |
+ /> |
|
193 | 192 |
|
194 | 193 |
<Button |
195 | 194 |
android:id="@+id/btn_confirm_ip" |
@@ -210,6 +209,59 @@ |
||
210 | 209 |
|
211 | 210 |
</LinearLayout> |
212 | 211 |
|
212 |
+ <View |
|
213 |
+ android:layout_width="match_parent" |
|
214 |
+ android:layout_height="1px" |
|
215 |
+ android:background="@color/text_hint_grey_color"/> |
|
216 |
+ |
|
217 |
+ <LinearLayout |
|
218 |
+ android:id="@+id/layout_query_interval" |
|
219 |
+ android:layout_width="match_parent" |
|
220 |
+ android:layout_height="wrap_content" |
|
221 |
+ android:paddingRight="6dp" |
|
222 |
+ android:orientation="vertical" |
|
223 |
+ android:visibility="visible"> |
|
224 |
+ |
|
225 |
+ <TextView |
|
226 |
+ android:layout_width="match_parent" |
|
227 |
+ android:layout_height="44dp" |
|
228 |
+ android:gravity="center_vertical" |
|
229 |
+ android:text="@string/camera_query_interval" |
|
230 |
+ android:paddingLeft="10dp" |
|
231 |
+ android:textColor="@color/dark_grey" |
|
232 |
+ android:textSize="16sp" /> |
|
233 |
+ |
|
234 |
+ <EditText |
|
235 |
+ android:id="@+id/et_query_interval" |
|
236 |
+ android:layout_width="match_parent" |
|
237 |
+ android:layout_height="44dp" |
|
238 |
+ android:layout_marginLeft="8dp" |
|
239 |
+ android:layout_marginRight="8dp" |
|
240 |
+ android:inputType="number" |
|
241 |
+ android:gravity="center" |
|
242 |
+ android:textSize="16sp" |
|
243 |
+ android:textColor="@color/dark_grey" |
|
244 |
+ /> |
|
245 |
+ |
|
246 |
+ <Button |
|
247 |
+ android:id="@+id/btn_confirm_interval" |
|
248 |
+ android:layout_width="wrap_content" |
|
249 |
+ android:layout_height="wrap_content" |
|
250 |
+ android:text="@string/ok" |
|
251 |
+ android:layout_gravity="center_horizontal" |
|
252 |
+ android:textSize="16sp" |
|
253 |
+ android:textColor="@color/white" |
|
254 |
+ android:background="@drawable/print_rounded_rect_bg" |
|
255 |
+ android:layout_marginTop="8dp" |
|
256 |
+ android:layout_marginBottom="8dp" |
|
257 |
+ android:paddingLeft="35dp" |
|
258 |
+ android:paddingRight="35dp" |
|
259 |
+ android:paddingBottom="5dp" |
|
260 |
+ android:paddingTop="5dp"/> |
|
261 |
+ |
|
262 |
+ |
|
263 |
+ </LinearLayout> |
|
264 |
+ |
|
213 | 265 |
<Button |
214 | 266 |
android:id="@+id/btn_user_logout" |
215 | 267 |
android:layout_width="match_parent" |
@@ -85,6 +85,8 @@ |
||
85 | 85 |
|
86 | 86 |
<string name="box_set_ip">BOX IP设置</string> |
87 | 87 |
|
88 |
+ <string name="camera_query_interval">照片轮询间隔设置(ms)</string> |
|
89 |
+ |
|
88 | 90 |
<string name="send">发送</string> |
89 | 91 |
<string name="feedback_hint">您的建议是我们前进的动力</string> |
90 | 92 |
<string name="thank_feedback">已发送,感谢您的宝贵意见</string> |